package cn.wen.core.banner;

import android.content.Context;

import cn.wen.base.adapter.viewpager.PagerHolder;
import cn.wen.base.adapter.viewpager.PagerHolderCreator;
import cn.wen.base.adapter.viewpager.QuickPagerHolder;
import cn.wen.core.R;


/**
 * 轮播图
 */
public abstract class BannerCreator<T> implements PagerHolderCreator {

    @Override
    public PagerHolder createViewPagerHolder() {
        return new BannerHolder();
    }

    protected abstract void onBindData(QuickPagerHolder<T> holder, Context context, int position, T t);

    private class BannerHolder extends QuickPagerHolder<T> {

        @Override
        protected void onBind(QuickPagerHolder<T> holder, Context context, int position, T t) {
            onBindData(holder, context, position, t);
        }

        @Override
        public int getLayoutId() {
            return getLayout();
        }
    }

    protected int getLayout() {
        return R.layout.item_view_banner;
    }

}
